Worksheet 4, Math 151

Linear Approximation

Introduction

Goals: Previously, we have learned about differentials and linear approximations. We saw the formula d y=((d y)/(d x))d x, and we have seen how we can use this formula to obtain a linear approximation of a function by replacing the abstract "infinitesmal changes" with actual differences. Perhaps we have even computed the formulas for some of these differentials. This lab will further explore the concept by computing and plotting some of these linear approximations.

Examples

We learned that the linear approximation to f centered at x=a is l(x)=f(a)+f'(a)(x-a). That is, the tangent line to y=f(x) at x=a is: y=f(a)+f'(a)(x-a).
We can use it to approximate f(x) when x is near a.

We illustrate this with a linear approximation to sin(x) centered at x=(π/6).

l[x_]:=Sin[Pi/6]+Cos[Pi/6]*(x-Pi/6)

Plot[{Sin[x],l[x]},{x,0,Pi/3},PlotStyle->{Green,Red}]

You can see that when x is near (π/6), l(x) (the red line) approximates the green curve.
For example, at x=0.6 (which is near x=(π/6)):

N[Sin[0.6]]
N[l[0.6]]

Example 1

The linear approximation above to the sine function centered at x=(π/6) is pretty accurate near (π/6). But it gets worse as x moves further away from (π/6).
When we use an approximation l(x) of f(x) centered at x=a, we want a guarantee that the approximation is quite accurate when x is close enough to a.
The error of this approximation at any point x is |l(x)-sin(x)|. So if we want accuracy to within 0.02, we need |l(x) - sin(x)|≤0.02. Equivalently, we can write sin(x)-0.02≤l(x)≤sin(x)+0.02.
We can plot sin(x) and l(x) together with tolerance bands at sin(x)-0.02 amd sin(x)+0.02 over a range of x-values and see for which values of x this is true.

Plot[{Sin[x],l[x],Sin[x]+0.02,Sin[x]-0.02},{x,0,Pi/3},PlotStyle->{Green,Red,Blue,Blue}]

It looks like l(x) is a reasonably good approximation, i.e., lies within our specified tolerance, between roughly x=0.23 and x=0.78.

Example 2

Here's the linear approximation, l(x), again: 
l(x) = f(a) + f' (x) (x - a).
A linear approximation is good, but one can do better.
A quadratic function is still not that difficult to work with, so a quadratic approximation can be useful.

Definition: The quadratic approximation of f(x) centered at the point x=a is q(x)=f(a)+f'(x)(x-a)+f''(x)(((x-a))^2)/2.
Since l(x) is the linear approximation to f(x) at x=a we can also write q(x)=l(x)+f''(a)(((x-a))^2)/2. 
So its form is similar to that of the linear approximation but with an additional modifying term.

The quadratic approximate of sin(x) centered at x=(π/6) is:

q[x_]:=Sin[Pi/6]+Cos[Pi/6]*(x-Pi/6)-Sin[Pi/6]*(x-Pi/6)^2/2

We plot this together with the linear approximation and sin(x):

Plot[{Sin[x],l[x],q[x]},{x,0,Pi/3},PlotStyle->{Green,Red,Orange}]

Look at how the colors are assigned.  The green curve should be sin(x), the red curve is l(x), and the orange curve is q(x).

Exercises

Exercise 1

Consider the linear approximation in Example 1 above.

Compute the absolute error e(x)=|f(x)-l(x)|.

Plot this function over the interval [0, 2π].

Find the maximum of e(x) in the interval above. (Note: Solve cannot solve the equation e'(x)=0. Use FindRoot instead.)

How far can we move away from (Subscript[x, 0])=(π/6) so that the error is no larger than 0.05? You may answer this question graphically.

Exercise 2

Make a similar plot as in Example 1, but change the domain and the tolerance band so that we can see a "close-up" near x=0.3 and get an estimate of where l(x) exits the range of accuracy 0.01.
Using the plot, estimate the x-value.
In other words, we want to know where l(x) crosses sin(x)-0.01 or sin(x)+0.01.

It so happens that l(x) crosses sin(x)+0.01 at the point of interest. The following command tries to find an x-value between 0.2 and 0.45 for which  l(x)=sin(x)+0.01.

FindRoot[l[x]==Sin[x]+0.01,{x,0.2,0.45}]

There is another point where l(x) crosses the tolerance bands. Follow the same steps (make a new plot, use FindRoot) to find the other x-value where l(x) exits the desired tolerance band for an accuracy of 0.01. (Start by making another plot over a wider domain, and using it to determine whether we need l(x)=sin(x)+0.01 or l(x)=sin(x)-0.01.)

For what values of x (an interval) is l(x) accurate to within 0.1?
Also, illustrate this with a plot.  (You need to repeat everything so far, and modify it for this situation.)

Exercise 3

Make a plot of the quadratic approximation q(x) (from Example 2) and the linear approximation l(x) (from Example 1) over the region [0.4,0.6].

Make a new plot with larger domain, until it's obvious which curve is which, based on your knowledge of simple curves. Also, explain how you can tell which is which.

l(x) and q(x) are approximations of sin(x). Which one is the closer approximation?  Which has the simpler formula?